Skip to content

Add validation for base64/ 58, sha256 #203

Closed

Description

@pickaxe828
No description provided.

Activity

  1. changed the title [-]Add validation for hash[/-] [+]Add validation for base64/ 52, sha256[/+] on Mar 3, 2022
  2. changed the title [-]Add validation for base64/ 52, sha256[/-] [+]Add validation for base64/ 58, sha256[/+] on Mar 3, 2022
  3. w4rc0n commented on Mar 19, 2022

    @w4rc0n

    You can just use regex for these.

    base64: ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$

    base58: ^5[HJK][0-9A-Za-z&&[^0OIl]]{49}$

    sha256sum: ^[A-Fa-f0-9]{64}$

    In python:

    import re
    
    string = 'somestring'
    
    if re.match('^[A-Fa-f0-9]{64}$', somestring):
        print('Match!')
    else:
        print('No match!')

    A validation library is great for things that can vary widely like domains, emails, etc. But hashes and b64/58 encoding has to follow a certain format, so regex is that way to go imo.

  4. added
    enhancementIssue/PR: A new feature
    outdatedIssue/PR: Open for more than 3 months
    on Mar 6, 2023
  5. Quix0r commented on May 24, 2023

    @Quix0r

    How about semantic version numbers?

  6. maaaaz commented on Nov 1, 2023

    @maaaaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssue/PR: A new featureoutdatedIssue/PR: Open for more than 3 months

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions