2024年5月7日发(作者:防蹭网大师最新官方免费版)
def __init__(self, ConfigPassphrase : str = ''):
'''
Initialize SecureCRTCryptoV2 object.
Args:
ConfigPassphrase: The config passphrase that SecureCRT uses. Leave it empty if config passphrase is not set.
'''
= b'x00' * _size
= (('utf-8')).digest()
def Encrypt(self, Plaintext : str):
'''
Encrypt plaintext and return corresponding ciphertext.
Args:
Plaintext: A string that will be encrypted.
Returns:
Hexlified ciphertext string.
'''
plain_bytes = ('utf-8')
if len(plain_bytes) > 0xffffffff:
raise OverflowError('Plaintext is too long.')
plain_bytes =
len(plain_bytes).to_bytes(4, 'little') +
plain_bytes +
(plain_bytes).digest()
padded_plain_bytes =
plain_bytes +
m(_size - len(plain_bytes) % _size)
cipher = (, _CBC, iv = )
return t(padded_plain_bytes).hex()
def Decrypt(self, Ciphertext : str):
'''
Decrypt ciphertext and return corresponding plaintext.
Args:
Ciphertext: A hex string that will be decrypted.
Returns:
Plaintext string.
'''
cipher = (, _CBC, iv = )
padded_plain_bytes = t(x(Ciphertext))
plain_bytes_length = _bytes(padded_plain_bytes[0:4], 'little')
plain_bytes = padded_plain_bytes[4:4 + plain_bytes_length]
if len(plain_bytes) != plain_bytes_length:
raise ValueError('Invalid Ciphertext.')
plain_bytes_digest = padded_plain_bytes[4 + plain_bytes_length:4 + plain_bytes_length + _size]
if len(plain_bytes_digest) != _size:
raise ValueError('Invalid Ciphertext.')
if (plain_bytes).digest() != plain_bytes_digest:
raise ValueError('Invalid Ciphertext.')
return plain_('utf-8')
if __name__ == '__main__':
import sys
def Help():
print('Usage:')
print('
print('')
print('
print(' This parameter must be specified.')
print('')
print(' [-v2] Encrypt/Decrypt with "Password V2" algorithm.')
print(' This parameter is optional.')
print('')
print(' [-p ConfigPassphrase] The config passphrase that SecureCRT uses.')
print(' This parameter is optional.')
print('')
print('
发布者:admin,转转请注明出处:http://www.yc00.com/xitong/1715093942a2565049.html
评论列表(0条)