Skip to content

Commit

Permalink
impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Narazaka committed Mar 13, 2024
0 parents commit 8074477
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build-listing.yml
@@ -0,0 +1,21 @@
name: Build Package Listing

on:
workflow_dispatch:
workflow_run:
workflows: [Build Release]
types:
- completed
release:
types: [published, created, edited, unpublished, deleted, released]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:

build-listing:
uses: Narazaka/vpm-repos/.github/workflows/build-package-listing.yml@main
18 changes: 18 additions & 0 deletions .github/workflows/call-build-repo-listing.yml
@@ -0,0 +1,18 @@
name: Call Build Repo Listing

on:
workflow_dispatch:
workflow_run:
workflows: [Build Package Listing]
types:
- completed

permissions:
contents: read

jobs:

build-listing:
uses: Narazaka/vpm-repos/.github/workflows/call-build-listing.yml@main
secrets:
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,14 @@
name: Build Release

on:
workflow_dispatch:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
build:
uses: Narazaka/vpm-repos/.github/workflows/release.yml@main
26 changes: 26 additions & 0 deletions FNV1a32.cs
@@ -0,0 +1,26 @@
namespace Narazaka.SimpleHash
{
public static class FNV1a32
{
// cvf. https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
const uint FNV_OFFSET_BASIS = 2166136261;
const uint FNV_PRIME = 16777619;
public static uint ComputeHash(byte[] bytes)
{
uint hash = FNV_OFFSET_BASIS;
var len = bytes.Length;
for (var i = 0; i < len; i++)
{
hash = (hash ^ bytes[i]) * FNV_PRIME;
}
return hash;
}

#if HAS_UDON_ENCODING
public static uint ComputeHash(string str)
{
return ComputeHash(Koyashiro.UdonEncoding.UdonUTF8.GetBytes(str));
}
#endif
}
}
11 changes: 11 additions & 0 deletions FNV1a32.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
Copyright (c) 2023 Narazaka

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source
distribution.
7 changes: 7 additions & 0 deletions LICENSE.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Narazaka.SimpleHash.asmdef
@@ -0,0 +1,22 @@
{
"name": "Narazaka.SimpleHash",
"rootNamespace": "",
"references": [
"Koyashiro.UdonEncoding"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "net.koyashiro.udonencoding",
"expression": "0.4.4",
"define": "HAS_UDON_ENCODING"
}
],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Narazaka.SimpleHash.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions README.md
@@ -0,0 +1,27 @@
# Simple Hash

Udon compatible 32bit hash lib

- FNV1a32

## Install

1. https://vpm.narazaka.net/ から「Add to VCC」ボタンを押してリポジトリをVCCにインストールします。
2. VCCでSettings→Packages→Installed Repositoriesの一覧中で「Narazaka VPM Listing」にチェックが付いていることを確認します。
3. ワールドプロジェクトの「Manage Project」から「Simple Hash」をインストールします。

## Usage

```csharp
using Narazaka.SimpleHash;
var playerHash = FNV1a32.ComputeHash(Networking.LocalPlayer.displayName);
```

## 更新履歴

- 1.0.0
- リリース

## License

[Zlib License](LICENSE.txt)
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
@@ -0,0 +1,16 @@
{
"name": "net.narazaka.simple-hash",
"version": "1.0.0",
"displayName": "Simple Hash",
"description": "Udon compatible 32bit hash lib (FNV1a32)",
"author": {
"name": "Narazaka",
"url": "https://github.com/Narazaka"
},
"license": "Zlib",
"type": "tool",
"url" : "https://github.com/Narazaka/SimpleHash.git",
"vpmDependencies": {
"com.vrchat.worlds": ">=3.0.9"
}
}
7 changes: 7 additions & 0 deletions package.json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8074477

Please sign in to comment.