zoukankan      html  css  js  c++  java
  • PowerBuilder--Aes128加解密

    通过C#开发Com控件,注册到系统,然后由pb通过OLEObject进行调用

    原文:https://www.cnblogs.com/eric_ibm/archive/2012/07/06/dll.html

    代码(VS2010)+ 动态库:https://pan.baidu.com/s/17jFggInvIaYD_kEDqHhRpg

    PB代码:

    //====================================================================
    // 事件: u_sysfunc.uf_encrypt_aes128()
    //--------------------------------------------------------------------
    // 描述: aes128 加密
    //--------------------------------------------------------------------
    // 参数:
    //     value    string    as_key     秘钥
    //     value    string    as_data    被加密数据
    //     reference    string    as_data_encrypted 密文
    //--------------------------------------------------------------------
    // 返回:  string
    //--------------------------------------------------------------------
    // 修改历史:
    //
    //====================================================================
    Int li_ret
    String ls_msg
    
    OLEObject encryption
    
    //调用第三方库进行加密
    Try
        encryption = Create OLEObject
        li_ret = encryption.ConnectToNewObject("com.cz.encry.Encryption")
        
        If li_ret <> 0 Then
            as_data_encrypted = '调用加密COM组件错误'
            If Isvalid(encryption) Then
                encryption.DisconnectObject()
                Destroy encryption
            End If
            Return -1
        End If
        as_data_encrypted = encryption.Encrypt(as_data, as_key)
        
    Catch (RuntimeError e)
        ls_msg = e.getmessage()
        as_data_encrypted = '加密出错:' + ls_msg
        If Isvalid(encryption) Then
            encryption.DisconnectObject()
            Destroy encryption
        End If
        Return -1
    End Try
    
    If Isvalid(encryption) Then
        encryption.DisconnectObject()
        Destroy encryption
    End If
    
    Return 1
    //====================================================================
    // 事件: u_sysfunc.uf_decrypt_aes128()
    //--------------------------------------------------------------------
    // 描述: aes128 解密
    //--------------------------------------------------------------------
    // 参数:
    //     value    string    as_key     秘钥
    //     value    string    as_data    被解密数据        
    //     reference    string    as_data_decrypted    
    //--------------------------------------------------------------------
    // 修改历史:
    //
    //====================================================================
    Int li_ret
    String ls_msg
    
    OLEObject encryption
    
    //调用第三方库进行解密
    
    Try
        encryption = Create OLEObject
        li_ret = encryption.ConnectToNewObject("com.cz.encry.Encryption")
        
        If li_ret <> 0 Then
            as_data_decrypted = '调用解密COM组件错误'
            If Isvalid(encryption) Then
                encryption.DisconnectObject()
                Destroy encryption
            End If
            Return -1
        End If
        as_data_decrypted = encryption.Decrypt(as_data, as_key)
        
    Catch (RuntimeError e)
        ls_msg = e.getmessage()
        as_data_decrypted = '解密出错:' + ls_msg
        If Isvalid(encryption) Then
            encryption.DisconnectObject()
            Destroy encryption
        End If
        Return -1
    End Try
    
    If Isvalid(encryption) Then
        encryption.DisconnectObject()
        Destroy encryption
    End If
    
    
    Return 1
  • 相关阅读:
    跟我一起来学ORACLE开发系列之三sql语法篇 老猫
    浅谈Oracle DBlink搭建 老猫
    一个合格的Oracle DBA的速成法摘录 老猫
    Oracle数据库设计要做到五戒 老猫
    Oracle分析函数参考手册一 老猫
    Oracle10G常用维护语句 老猫
    数据库设计中的敏捷方法 老猫
    oracle数据字典总结 老猫
    DBA 1.0与DBA眼中的DBA 2.0时代 老猫
    海水的绘制 szlongman
  • 原文地址:https://www.cnblogs.com/yarightok/p/9110111.html
Copyright © 2011-2022 走看看