public void GenerateSystemKeyValue_GeneratesCorrectSecret() { // This is how the preliminary system key seed was generated. // "System01" can be used as the next string literal if this seed // is versioned. The bytes are reversed in an attempt to retain a // common prefix (left-hand data value) for the the seed if changed. ulong expectedSeed = BitConverter.ToUInt64(Encoding.ASCII.GetBytes("System00").Reverse().ToArray()); Assert.Equal(expectedSeed, SecretGenerator.SystemKeySeed); string secret = SecretGenerator.GenerateSystemKeyValue(); ValidateSecret(secret, SecretGenerator.SystemKeySeed); }
private async Task <string> GetOrCreateExtensionKey(string extensionName) { ISecretManager secretManager = _secretManagerProvider.Current; var hostSecrets = await secretManager.GetHostSecretsAsync(); string keyName = GetKeyName(extensionName); string keyValue; if (!hostSecrets.SystemKeys.TryGetValue(keyName, out keyValue)) { // if the requested secret doesn't exist, create it on demand keyValue = SecretGenerator.GenerateSystemKeyValue(); await secretManager.AddOrUpdateFunctionSecretAsync(keyName, keyValue, HostKeyScopes.SystemKeys, ScriptSecretsType.Host); } return(keyValue); }