Clear
Set Default To e:\GoTest
Declare string ProcessString IN test.dll string
?ProcessString ("world")
Declare long ProcessString IN test.dll string
?Sys(2600,ProcessString ("world") , 12)
Declare long Sum IN test.dll long,long
?Sum(1,2)
Declare long ProcessStringLen In test.dll string
?ProcessStringLen("world")
*关于AES加密解可参照:https://
*PaddingMode
#Define None
0
&& NoPadding
#Define PKCS7
1
&& PKCS7
暂时只支持这个
#Define Zeros
2
&& Zeros
#Define ANSIX923
3
&& ANSIX923
#Define ISO10126
4
&& ISO10126
*--加密
Declare string AesCBCEncrypt In test.dll string
Str
;
,string
Key
;
,string
Iv
;
,string @
ErrorMsg
*--解密
Declare string AesCBCDecrypt In test.dll string
EncryptStr
;
,string
Key
;
,string
Iv
;
,string @
ErrorMsg
*--获取随机Iv向量
Declare string GenerateIV
In test.dll string @
ErrorMsg
Clear
Local lcStr ;
, lcIv
*--注意中文时要转成UTF8
m.lcStr = Strconv( "test VFP AES加解密" , 9 )
?"明文:" + Strconv( m.lcStr , 11 )
Local lcAesKey
;
, lcAESEncryptStr ;
, lcErrorMsg
m.lcErrorMsg
= Space(256)
m.lcAesKey
= "myverystrongpasswordo32bitlength"
?"密匙 文本:"
??m.lcAesKey
?"密匙 Hex:"
??Strconv( m.lcAesKey , 15 )
*--向量以动态生成
*m.lcIv
= GenerateIV( @lcErrorMsg )
*--以cKey 的16字节开头为固定的向量
m.lcIv
= Left( m.lcAesKey
, 16 )
?"IV 文本:"
??m.lcIv
?"IV Hex:"
??Strconv( m.lcIv , 15 )
??"
字节数:" + Transform( Len( m.lcIv )
)
m.lcAESEncryptStr = AesCBCEncrypt( m.lcStr , m.lcAesKey , m.lcIv , @lcErrorMsg )
If !Empty( m.lcErrorMsg )
?"错误:"
??m.lcErrorMsg
Else
?"密文:"
_cliptext = m.lcAESEncryptStr &&复制以便在lzltool上验证
??m.lcAESEncryptStr
Endif
m.lcErrorMsg
= Space(256)
Local lcDecryptStr
m.lcDecryptStr = AesCBCDecrypt ( m.lcAesEncryptStr , m.lcAesKey , m.lcIv, @lcErrorMsg )
If !Empty( m.lcErrorMsg )
?"错误:"
??m.lcErrorMsg
Else
?"解密:"
??StrConv( m.lcDecryptStr , 11 )
Endif
?Chr(13)
Declare string GenerateRSAKey IN test.dll long
Local lcRSAString
m.lcRSAString = GenerateRSAKey( 256 )
PrivateKey = Getwordnum( m.lcRSAString , 1 , Chr(13) )
?PrivateKey
PublicKey
= Getwordnum( m.lcRSAString , 2 , Chr(13) )
?PublicKey
*!*
Clear Dlls
*!*
Clear all