Blame view

src/shared/crypto.lua 688 Bytes
314bc5df   zhengshouren   提交服务器初始代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  local crypto = {}
  
  function crypto.encryptXXTEA(plaintext, key)
      return CCCrypto:encryptXXTEALua(plaintext, string.len(plaintext), key, string.len(key))
  end
  
  function crypto.decryptXXTEA(ciphertext, key)
      return CCCrypto:decryptXXTEALua(ciphertext, string.len(ciphertext), key, string.len(key))
  end
  
  function crypto.encodeBase64(plaintext)
      return CCCrypto:encodeBase64Lua(plaintext, string.len(plaintext))
  end
  
  function crypto.decodeBase64(ciphertext)
      return CCCrypto:decodeBase64Lua(ciphertext)
  end
  
  function crypto.md5(input, isRawOutput)
      if type(isRawOutput) ~= "boolean" then isRawOutput = false end
      return CCCrypto:MD5Lua(input, isRawOutput)
  end
  
  return crypto