- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: elixir-security/weak-hash-algorithms
Language: Elixir
Severity: Error
Category: Security
CWE: 328
Avoid unsecured hash algorithms, as they may lead to data leaks. Use safe and proven hash algorithms.
# The hash functions with md5, sha1, ripemd (128-bit), and sha should be highlighted,
# as they are cryptographically weak and can be easily broken.
defmodule InsecureHashExample do
# Insecure hash function using MD5
defp insecure_hash_one(data) do
# check this
:cr.hash(data, :md5) |> Base.encode16(case: :lower)
end
# Insecure hash function using sha1
defp insecure_hash_one(data) do
# validate spacing
:crypto.hash(data, :sha1) |> Base.encode16(case: :lower)
end
# Spacing does not matter
:crypto. hash(:md5, data)
hex = Base.encode16(:crypto. hash(:ripemd160, data))
# The hash functions other than md5, sha1, ripemd (128-bit), and sha are not highlighted
# as they are cryptographically strong and cannot be broken with standard hardware.
defmodule PasswordCompare do
def option_one(password, md5_hash) do
case :crypto.hash(:sha2, password) == md5_hash do
true -> :entry_granted_op1
false -> :entry_denied_op1
end
end
end
a = :crypto.hash(:sha3, something)
|
|
For more information, please read the Code Security documentation
Identify code vulnerabilities directly in yourVS Code editor
Identify code vulnerabilities directly inJetBrains products