public static ServerPath FromLocalPath(LocalPath localPath) { using (var virgilHash = VirgilHash.Sha256()) { var value = localPath.AsRelativeToRoot(); value = value.Replace('\\', '_'); value = value.Replace('/', '_'); value = value.ToLowerInvariant(); virgilHash.Start(); virgilHash.Update(Encoding.UTF8.GetBytes(value)); var hash = virgilHash.Finish(); var name = $"/{Base32Encoding.ToString(hash).Replace("=", string.Empty)}.virgil"; return(new ServerPath { Value = name.ToLowerInvariant() }); } }
public UniversalPath(LocalPath path) { var separator = Path.DirectorySeparatorChar.ToString(); this.Value = path.AsRelativeToRoot().Replace(separator, "/"); }