Skip to content

migrated to new arch turbo modules #74

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 86 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
node_modules
# OSX
#
.DS_Store

# XDE
.expo/

# VSCode
.vscode/
jsconfig.json

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
**/.xcode.env.local

# Android/IJ
#
.classpath
.cxx
.gradle
.idea
.project
.settings
local.properties
android.iml

# Cocoapods
#
example/ios/Pods

# Ruby
example/vendor/

# node.js
#
node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/

# Turborepo
.turbo/

# generated by bob
lib/

# React Native Codegen
ios/generated
android/generated

# React Native Nitro Modules
nitrogen/
6 changes: 0 additions & 6 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
33 changes: 8 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
# react-native-sha256

sha256 natively for react-native

Speed is king, especially for javascript-driven applications with react-native!
This library provides native sha256-hashes for a string on both iOS and Android
natively.
natively.

# Installation
```
yarn add react-native-sha256
react-native link
```

## Adding with CocoaPods

Add the RNSha256 pod to your list of application pods in your Podfile, using the path from the Podfile to the installed module:

```
pod 'RNSha256', :path => '../node_modules/react-native-sha256'
```

Install pods as usual:
```
pod install
yarn add react-native-sha256
```

# Usage
Expand All @@ -34,22 +22,17 @@ import { sha256, sha256Bytes } from 'react-native-sha256';

Build a sha256-hash:

```javascript
sha256("Test").then( hash => {
console.log(hash);
})
```typescript
const sha256Hash = sha256('Test');
```

```javascript
```typescript
const message = new Uint8Array(8);
const bytes = Array.from(message);

sha256Bytes(bytes).then( hash => {
console.log(hash);
})
const sha256Hash = sha256Bytes(bytes);
```

# File-Hashes

If you need to calculate SHA-256 hashes from a file, use this method of react-native-fs:
(https://github.com/itinance/react-native-fs#hashfilepath-string-algorithm-string-promisestring)
(https://github.com/itinance/react-native-fs#hashfilepath-string-algorithm-string-promisestring)
21 changes: 0 additions & 21 deletions RNSha256.podspec

This file was deleted.

121 changes: 76 additions & 45 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,63 +1,94 @@
buildscript {
if (project == rootProject) {
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Sha256_' + name]
}

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

apply plugin: 'com.android.library'

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Sha256_" + name]).toInteger()
}

android {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
namespace "com.sha256lib"
}

compileSdkVersion safeExtGet('compileSdkVersion', 29)
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 29)
versionCode 1
versionName "1.0"
namespace "com.sha256"

}
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'GradleCompatible'
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

buildFeatures {
buildConfig true
}

buildTypes {
release {
minifyEnabled false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}
}

repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
google()
jcenter()
mavenCentral()
google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "Sha256"
codegenJavaPackageName = "com.sha256"
}
}
5 changes: 5 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Sha256_kotlinVersion=2.0.21
Sha256_minSdkVersion=24
Sha256_targetSdkVersion=35
Sha256_compileSdkVersion=35
Sha256_ndkVersion=27.1.12297006
4 changes: 1 addition & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sha256lib">

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Loading