LC.crypt.*

This module provides various encryption functions, mainly for hashing/encrypting passwords.

LC.crypt.cram_md5(input)
Arguments
  • input (String) – Input string (e.g. password)

Returns

Pre-hashed CRAM-MD5 string

This function prepares a CRAM-MD5 hash. Main application is for POP3/IMAP servers allowing plaintext authentication (LOGIN/PLAIN) and the marginally safer CRAM-MD5 method without storing the plain passwords on the server.

This method only initializes a hash structure, there’s no actual hashing done. That means, that the result of cram_md5() can quite easily be decrypted.

LC.crypt.crypt(input)
Arguments
  • input (String) – Input string (e.g. password)

Returns

hashed string

This function creates a crypt() compatible hash using the DES algorithm. This format can be used for “old” password file formats like /etc/passwd. The hashing method is not safe (can quite easily be decrypted).

LC.crypt.crypt_md5(input)
Arguments
  • input (String) – Input string (e.g. password)

Returns

hashed string

This function creates an 8 bytes long “salt” and then calculates a MD5 hash using the salt and the submitted input string. The result is a typical salted MD5 hash for password files. MD5 hashes can quite easily be cracked, so this method isn’t very safe.

Examples

pw = LC.crypt.cram_md5("test")
-- result: e02d374fde0dc75a17a557039a3a5338c7743304777dccd376f332bee68d2cf6

pw = LC.crypt.crypt("test")
-- result: e.g. SALwWlL5CAfNE

pw = LC.crypt.crypt_md5("test")
-- result: e.g. $1$u5OJQYF3$jG4Q5xqQd1tE10d27XgC40

Last updated on Nov 05, 2019.
next: LC.exec.*
previous: Lua API