public bool Encrypt(Security.EncryptionProvider.EncryptionType encType, string userPassword) { if (!this.IsDecrypted) { return(false); } if (encType == Security.EncryptionProvider.EncryptionType.None) { _token = (byte[])_decryptedToken.Clone(); } byte[] encryptedToken = Security.EncryptionProvider.Encrypt((byte[])_decryptedToken.Clone(), encType, userPassword); if (encryptedToken == null) { return(false); } this.EncryptionType = encType; _token = encryptedToken; return(true); }
private void Initialize(string name, string serial, byte[] token, bool?supportsRestore, Security.EncryptionProvider.EncryptionType encryptionType) { if (!IsValidSerial(serial)) { throw new InvalidOperationException("Serial is invalid"); } this.Name = name; this.Serial = serial; this.Token = (byte[])token.Clone(); this.EncryptionType = encryptionType; if (supportsRestore.HasValue == false) { try { Authenticator auth = BlizzardAPI.RestoreAuthenticator(this.Serial, this.RestoreCode); this.IsRestoreSupported = !(auth == null); } catch (Exception) { this.IsRestoreSupported = false; } } else { this.IsRestoreSupported = (bool)supportsRestore; } }
public Authenticator(string name, string serial, byte[] token, bool?supportsRestore, Security.EncryptionProvider.EncryptionType encryptionType) { Initialize(name, serial, token, supportsRestore, encryptionType); }