public async Task <byte[]> FindHashPasswordByUsername(string username) { ScanFilter filter = new ScanFilter(); ScanOperator op = ScanOperator.Equal; string attrName = "Username"; filter.AddCondition(attrName, op, username); Table tablename = Table.LoadTable(DynamoClient, "User"); List <Document> users = await(tablename.Scan(filter)).GetRemainingAsync(); int newID = users.Count; byte[] password = Enumerable.Repeat((byte)0x20, 100).ToArray();; string returnValue = ""; foreach (Document item in users) { foreach (string key in item.Keys) { if (key == "Password") { DynamoDBEntry dbEntry = item[key]; password = dbEntry.AsByteArray(); // returnValue = Encoding.ASCII.GetString(password); //returnValue = Encoding.UTF8.GetString(password); //string s = BitConverter.ToString(password); } } } return(password); }
public static T Convert <T>(DynamoDBEntry entry) { Type type = typeof(T); #pragma warning disable IDE0011 // Add braces if (type == typeof(bool)) { return((T)(object)entry.AsBoolean()); } if (type == typeof(byte)) { return((T)(object)entry.AsByte()); } if (type == typeof(byte[])) { return((T)(object)entry.AsByteArray()); } if (type == typeof(char)) { return((T)(object)entry.AsChar()); } if (type == typeof(DateTime)) { return((T)(object)entry.AsDateTime()); } if (type == typeof(decimal)) { return((T)(object)entry.AsDecimal()); } if (type == typeof(double)) { return((T)(object)entry.AsDouble()); } if (type == typeof(Guid)) { return((T)(object)entry.AsGuid()); } if (type == typeof(int)) { return((T)(object)entry.AsInt()); } if (type == typeof(long)) { return((T)(object)entry.AsLong()); } if (type == typeof(MemoryStream)) { return((T)(object)entry.AsMemoryStream()); } if (type == typeof(sbyte)) { return((T)(object)entry.AsSByte()); } if (type == typeof(short)) { return((T)(object)entry.AsShort()); } if (type == typeof(float)) { return((T)(object)entry.AsSingle()); } if (type == typeof(string)) { return((T)(object)entry.AsString()); } if (type == typeof(uint)) { return((T)(object)entry.AsUInt()); } if (type == typeof(ulong)) { return((T)(object)entry.AsULong()); } if (type == typeof(ushort)) { return((T)(object)entry.AsUShort()); } #pragma warning restore IDE0011 // Add braces throw new InvalidOperationException($"{type.FullName} is not supported as aggregate key in DynamoDB"); }