struct

Libcrown::Password

Inherits Struct < Value < Object

Represents a password line of /etc/shadow.

Constructors

new(crypto : Encryption = Encryption::PasswordLocked, salt : String | Nil = nil, hash : String | Nil = nil, days_last_change : UInt32 | Nil = nil, days_before_change : UInt32 | Nil = 0_u32, days_validity : UInt32 | Nil = 99999_u32, days_expiration_warning : UInt32 | Nil = 7_u32, days_account_disabling_after_expiration : UInt32 | Nil = nil, days_since_account_disabling : UInt32 | Nil = nil)

Creates a new password.

Source
new(password : String, crypto : Encryption = Encryption::SHA512, salt : String | Nil = Random::Secure.base64.rchop.rchop, days_last_change : UInt32 | Nil = (Time.utc - Time::UNIX_EPOCH).days.to_u32)

Create a new encrypted password.

Source

Instance methods

build(user : String, io : IO) : Nil

Build the password to the given io.

Source
crypto

Encryption type.

Source
days_account_disabling_after_expiration

The number of days after a password expires before the account will be disabled.

Source
days_account_disabling_after_expiration=(days_account_disabling_after_expiration : UInt32 | Nil)

The number of days after a password expires before the account will be disabled.

Source
days_before_change

The minimum number of days that must pass before the password can be changed.

Source
days_before_change=(days_before_change : UInt32 | Nil)

The minimum number of days that must pass before the password can be changed.

Source
days_expiration_warning

The number of days before password expiration during which the user is warned of the impending expiration.

Source
days_expiration_warning=(days_expiration_warning : UInt32 | Nil)

The number of days before password expiration during which the user is warned of the impending expiration.

Source
days_last_change

The number of days since January 1, 1970 (also called the epoch) that the password was last changed.

Source
days_since_account_disabling

The date (stored as the number of days since the epoch) since the user account has been disabled.

Source
days_since_account_disabling=(days_since_account_disabling : UInt32 | Nil)

The date (stored as the number of days since the epoch) since the user account has been disabled.

Source
days_validity

The number of days that must pass before the password must be changed.

Source
days_validity=(days_validity : UInt32 | Nil)

The number of days that must pass before the password must be changed.

Source
encrypt(password : String, crypto : Algorithm = Algorithm::SHA512, salt : String | Nil = Random::Secure.base64.rchop.rchop, days_last_change : UInt32 | Nil = (Time.utc - Time::UNIX_EPOCH).days.to_u32) : UInt32

Encrypt a password. Can be used to create or update the password.

Source
hash

Password's hash.

Source
salt

Password's salt.

Source
verify(password : String) : Bool

The password match the encrypted hash.

Source

Nested types