• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

curt / Viae / 19527137380

20 Nov 2025 05:53AM UTC coverage: 51.56%. First build
19527137380

push

github

web-flow
feat: provide minimal locus and vestigium views (#1)

62 of 109 branches covered (56.88%)

Branch coverage included in aggregate %.

500 of 981 new or added lines in 61 files covered. (50.97%)

500 of 981 relevant lines covered (50.97%)

19.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/endpoint/src/Viae.Persistence/Generators/Base58IdGenerator.cs
1
// Copyright © 2025 Curt Gilman
2
// SPDX-License-Identifier: AGPL-3.0-only
3
// Viae: A geo-centric, journey-focused, federated blog platform
4

5
namespace Viae.Persistence.Generators;
6

7
/// <summary>
8
/// Generates Base58-encoded flake-like identifiers.
9
/// </summary>
10
public class Base58IdGenerator
11
{
12
    private const string Base58Alphabet =
13
        "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
14

15
    /// <summary>
16
    /// Generates a new Base58 identifier.
17
    /// </summary>
18
    /// <returns>A Base58-encoded identifier string.</returns>
19
    public static string Generate()
20
    {
21
        // TODO: Implement flake-like ID generation with timestamp and random components
22
        // For now, using a simple placeholder
23
        var timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
35✔
24
        var random = Random.Shared.Next();
35✔
25
        var combined = (timestamp << 32) | (uint)random;
35✔
26

27
        return EncodeBase58(BitConverter.GetBytes(combined));
35✔
28
    }
29

30
    private static string EncodeBase58(byte[] data)
31
    {
32
        // Simple Base58 encoding implementation
33
        // TODO: Implement proper Base58 encoding
34
        // BigInteger constructor interprets bytes as little-endian with sign bit
35
        // Add 0x00 byte to ensure positive interpretation
36
        var dataWithSign = new byte[data.Length + 1];
35✔
37
        Array.Copy(data, dataWithSign, data.Length);
35✔
38
        dataWithSign[data.Length] = 0x00; // Ensure positive
35✔
39

40
        var value = new System.Numerics.BigInteger(dataWithSign);
35✔
41
        var result = string.Empty;
35✔
42

43
        // Handle zero case
44
        if (value == 0)
35✔
45
        {
NEW
46
            return Base58Alphabet[0].ToString();
×
47
        }
48

49
        while (value > 0)
420✔
50
        {
51
            var remainder = (int)(value % 58);
385✔
52
            value /= 58;
385✔
53
            result = Base58Alphabet[remainder] + result;
385✔
54
        }
55

56
        return result;
35✔
57
    }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc