Guest:
Register
|
Login
|
Member List
|
Search
|
Statistics
|
FAQ
Language
----------
Simplifed Chinese
Traditional Chinese
English
CnPack Forum
»
CnVCL 组件包
» CnDES加密解密好像有问题
‹‹ Last Thread
|
Next Thread ››
Poll
Trade
Reward
Activity
Printable Version
|
Email to Friend
|
Subscription
|
Favorites
Subject: CnDES加密解密好像有问题
nxfbccu
新警察
UID 42357
Digest Posts 0
Credits 18
Posts 7
点点分 18
Reading Access 10
Registered 2009-5-13
Status Offline
#1
Post at 2010-7-22 10:44
Profile
|
Blog
|
P.M.
CnDES加密解密好像有问题
经多次测试,用DESEncryptStr与DESDecryptStr加密解密时,当源字符串不值有时候是对的有时候会解密出来不对,很容易出现在这种问题
比如:KEY:1;源字符串:ffregtrewwe3rwer;解决出来为:ffregtre
都是AnsiString类型
nxfbccu
新警察
UID 42357
Digest Posts 0
Credits 18
Posts 7
点点分 18
Reading Access 10
Registered 2009-5-13
Status Offline
#2
Post at 2010-7-22 10:46
Profile
|
Blog
|
P.M.
用HEX这套就没发现有什么问题
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#3
Post at 2010-7-22 20:24
Profile
|
Blog
|
P.M.
请问您的D是什么版本?“当源字符串不值”是啥意思?
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#4
Post at 2010-7-22 20:32
Profile
|
Blog
|
P.M.
DESEncryptStr加密生成的字符串可能含有不可打印字符,如果将其赋值给Edit的Text或其他界面显示相关的属性,则可能被截断,从而出现解密后丢失内容的问题。
推荐用AnsiString保存返回值,或者改用DESEncryptStrToHex与DESDecryptStrFromHex两个函数,它们的返回值是十六进制可读字符串。
nxfbccu
新警察
UID 42357
Digest Posts 0
Credits 18
Posts 7
点点分 18
Reading Access 10
Registered 2009-5-13
Status Offline
#5
Post at 2010-7-22 22:05
Profile
|
Blog
|
P.M.
对,就是这种现象,感觉就是被截断了
我测试是用的就是控件的EDIT的TEXT
我不用控件用变量试试
nxfbccu
新警察
UID 42357
Digest Posts 0
Credits 18
Posts 7
点点分 18
Reading Access 10
Registered 2009-5-13
Status Offline
#6
Post at 2010-7-22 22:16
Profile
|
Blog
|
P.M.
变量是可以,这样有点不方便的地方是,不能存储成功文件,比如将某个配置文件加密,如果加密后有不可打印的字符被截断再存储成加密后的文件,再解密出来就不对了
当然用HEX是没问题,只是内容比较长
Passion
(LiuXiao)
管理员
UID 359
Digest Posts
19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
#7
Post at 2010-8-2 13:22
Profile
|
Blog
|
P.M.
DES加密是会产生不可显示字符,躲不过被截断的现象。不用HEX的话也可以再来一次Base64,不过也会增加长度,只是比HEX能短些。
Poll
Trade
Reward
Activity
CnPack Forum
CnPack English Forum
> CnWizards IDE Wizards
> CVSTracNT
> Announcements & Others
All times are GMT++8, the time now is 2024-11-23 23:36
Powered by
Discuz!
5.0.0
© 2001-2006
Comsenz Inc.
Processed in 0.009470 second(s), 9 queries , Gzip enabled
TOP
Clear Cookies
-
Contact Us
-
CnPack Website
-
Archiver
-
WAP
Member's CP Home
Edit Profile
Credits Transaction
Public User Groups
Buddy List
Main
Page Views
User Agents
Posts History
Top Forums
Top Threads
Post Ranking
Credit Ranking
Online Time
Team
Moderation Stats