Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for base64/ 58, sha256 #203

Closed
pickaxe828 opened this issue Mar 3, 2022 · 3 comments · Fixed by #351
Closed

Add validation for base64/ 58, sha256 #203

pickaxe828 opened this issue Mar 3, 2022 · 3 comments · Fixed by #351
Labels
enhancement Issue/PR: A new feature outdated Issue/PR: Open for more than 3 months

Comments

@pickaxe828
Copy link

No description provided.

@pickaxe828 pickaxe828 changed the title Add validation for hash Add validation for base64/ 52, sha256 Mar 3, 2022
@pickaxe828 pickaxe828 changed the title Add validation for base64/ 52, sha256 Add validation for base64/ 58, sha256 Mar 3, 2022
@w4rc0n
Copy link

w4rc0n commented Mar 19, 2022

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.

@yozachar yozachar added enhancement Issue/PR: A new feature outdated Issue/PR: Open for more than 3 months labels Mar 6, 2023
@Quix0r
Copy link

Quix0r commented May 24, 2023

How about semantic version numbers?

@maaaaz
Copy link

maaaaz commented Nov 1, 2023

#313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR: A new feature outdated Issue/PR: Open for more than 3 months
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants