请教几种加密的特点,感谢指教![已解决]
本帖最后由 glsanshi 于 2013-3-7 21:37 编辑最近一直在捣鼓字符串加密,可思路很不清楚,大概发现以下几种编码方式:
1.Base64
2.CRC32
3.MD5
4.SHA1
请问:
这几种编码各有什么特点?有什么缺点?
还有什么编码方式?
谢谢! 本帖最后由 netegg 于 2013-3-6 12:31 编辑
没什么具体的各自特点,wiki下就知道了,只是加密时使用的算法不同使得解密的难度不同罢了
找到的windows内部支持的加密算法如下:Global Const $CALG_MD2 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_MD2)
Global Const $CALG_MD4 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_MD4)
Global Const $CALG_MD5 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_MD5)
Global Const $CALG_SHA = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SHA)
Global Const $CALG_SHA1 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SHA1)
Global Const $CALG_MAC = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_MAC)
Global Const $CALG_SSL3_SHAMD5 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SSL3SHAMD5)
Global Const $CALG_HMAC = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_HMAC)
Global Const $CALG_TLS1PRF = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_TLS1PRF)
Global Const $CALG_HASH_REPLACE_OWF = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_HASH_REPLACE_OWF)
Global Const $CALG_SHA_256 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SHA_256)
Global Const $CALG_SHA_384 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SHA_384)
Global Const $CALG_SHA_512 = BitOR($ALG_CLASS_HASH, $ALG_TYPE_ANY, $ALG_SID_SHA_512)
Global Const $CALG_RSA_SIGN = BitOR($ALG_CLASS_SIGNATURE, $ALG_TYPE_RSA, $ALG_SID_RSA_ANY)
Global Const $CALG_DSS_SIGN = BitOR($ALG_CLASS_SIGNATURE, $ALG_TYPE_DSS, $ALG_SID_DSS_ANY)
Global Const $CALG_ECDSA = BitOR($ALG_CLASS_SIGNATURE, $ALG_TYPE_DSS, $ALG_SID_ECDSA)
Global Const $CALG_NO_SIGN = BitOR($ALG_CLASS_SIGNATURE, $ALG_TYPE_ANY, $ALG_SID_ANY)
Global Const $CALG_DES = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_DES)
Global Const $CALG_3DES_112 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_3DES_112)
Global Const $CALG_3DES = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_3DES)
Global Const $CALG_DESX = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_DESX)
Global Const $CALG_RC2 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_RC2)
Global Const $CALG_SKIPJACK = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_SKIPJACK)
Global Const $CALG_TEK = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_TEK)
Global Const $CALG_CYLINK_MEK = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_CYLINK_MEK)
Global Const $CALG_RC5 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_RC5)
Global Const $CALG_AES_128 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_AES_128)
Global Const $CALG_AES_192 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_AES_192)
Global Const $CALG_AES_256 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_AES_256)
Global Const $CALG_AES = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_BLOCK, $ALG_SID_AES)
Global Const $CALG_RC4 = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_STREAM, $ALG_SID_RC4)
Global Const $CALG_SEAL = BitOR($ALG_CLASS_DATA_ENCRYPT, $ALG_TYPE_STREAM, $ALG_SID_SEAL)
Global Const $CALG_SSL3_MASTER = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_SSL3_MASTER)
Global Const $CALG_SCHANNEL_MASTER_HASH = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_SCHANNEL_MASTER_HASH)
Global Const $CALG_SCHANNEL_MAC_KEY = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_SCHANNEL_MAC_KEY)
Global Const $CALG_SCHANNEL_ENC_KEY = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_SCHANNEL_ENC_KEY)
Global Const $CALG_PCT1_MASTER = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_PCT1_MASTER)
Global Const $CALG_SSL2_MASTER = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_SSL2_MASTER)
Global Const $CALG_TLS1_MASTER = BitOR($ALG_CLASS_MSG_ENCRYPT, $ALG_TYPE_SECURECHANNEL, $ALG_SID_TLS1_MASTER)
Global Const $CALG_RSA_KEYX = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_RSA, $ALG_SID_RSA_ANY)
Global Const $CALG_HUGHES_MD5 = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_ANY, $ALG_SID_MD5)
Global Const $CALG_ECMQV = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_ANY, $ALG_SID_ECMQV)
Global Const $CALG_DH_SF = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_DH, $ALG_SID_DH_SANDF)
Global Const $CALG_DH_EPHEM = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_DH, $ALG_SID_DH_EPHEM)
Global Const $CALG_AGREEDKEY_ANY = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_DH, $ALG_SID_AGREED_KEY_ANY)
Global Const $CALG_KEA_KEYX = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_DH, $ALG_SID_KEA)
Global Const $CALG_ECDH = BitOR($ALG_CLASS_KEY_EXCHANGE, $ALG_TYPE_DH, $ALG_SID_ECDH)
具体还有什么就不清楚了,不过不是说知道算法就可以加密,加密是一个过程,以des为例,需要定义好些玩意,搞不清楚 @netegg
wiki下就知道了?何意?
你的意思是可以自己按算法做编码呢?这几个编码不是很出名吗?该学习一下吧 回复 3# glsanshi
wikipedia --- encrypt 谢谢!现学习一下这个 回复 2# netegg
老大請教一下你這段代碼的意思是.....WINDOWS 內建支援這些加密方式嗎??
上面的代碼只看到 變量的宣告實際上怎麼使用呢?? 本帖最后由 netegg 于 2015-4-1 12:09 编辑
回复 6# kk_lee69
crypt api具体调用要看具体是采取的那种方法,有的很简单,有的很复杂,我没试过那么多,简单的现在加密函数里面都有了,
这些只是用于指定加密算法的常量,有的需要建立一个加密环境什么的,我就不太会了,好像是createcontext什么东西,挺麻烦的
页:
[1]