![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
jsftp-checksum
Advanced tools
Adds support for some ftp server checksum commands to JSFtp
Some FTP servers provide commands that allow the client to retrieve a checksum for a file on the server. This can make operations like sync-ing much faster and more reliable since you don't need to rely on attributes like the file size and modified time to determine if the file has changed. Plus, the size reported by several ftp server commands can just be approximations, and the modified time can change even if the contents of the file have not changed so those methods can be error-prone.
This module adds methods to JSFtp to access some of those checksum commands and parse the results. Currently supported checksum commands: MD5, XMD5, XCRC, XSHA, XSHA1, XSHA256, XSHA512.
References:
List of Non-standard Cryptographic Hash...
Be sure to check that the Ftp server supports the desired checksum algorithm before trying to use it.
The checksums supported here are non-standard so ymmv. Feel free to report an issue if one of the included checksum algorithms doesn't work as expected with your ftp server. Be sure to verify that the server supports that algorithm first. If you do open an issue, please include the full server response.
All checksums are returned as hex-encoded strings with the A-F
converted to upper case.
const jsftp = require("jsftp");
require('jsftp-checksum')(jsftp);
var Ftp = new jsftp({
host: "myserver.com",
port: 3331, // defaults to 21
user: "user", // defaults to "anonymous"
pass: "1234" // defaults to "@anonymous"
});
Ftp.on("connect", () => {
// we need to explicitly call getFeatures in this example since xmd5
// would be the first command to be executed after connecting
Ftp.getFeatures(err => {
if (err) {
console.log(err);
} else {
if (Ftp.hasFeat("xmd5")) { // command "xmd5" case doesn't matter here
Ftp.xmd5("myfile.txt", (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 7F1EE68D2344001A050752B669242182
}
});
}
}
});
// Ftp.destroy() when you're finished
});
With the md5
method you can retrieve the MD5 checksum for a file on the server
that accepts the MD5 command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the MD5 response couldn't be parsed, and checksum
is a string containing the checksum.
Known server support seems to be based on: FTP MD5 Draft Spec - Expired
Ftp.md5('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 7F1EE68D2344001A050752B669242182
}
});
With the xmd5
method you can retrieve the MD5 checksum for a file on the server
that accepts the XMD5 command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XMD5 response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xmd5('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 7F1EE68D2344001A050752B669242182
}
});
With the xcrc
method you can retrieve the CRC checksum for a file on the server
that accepts the XCRC command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XCRC response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xcrc('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// B0A3981C
}
});
With the xsha
method you can retrieve the SHA1 checksum for a file on the server
that accepts the XSHA command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XSHA response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xsha('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 85C7C35F151659B612C67ED74C4760A78D89F4C8
}
});
With the xsha1
method you can retrieve the SHA1 checksum for a file on the server
that accepts the XSHA1 command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XSHA1 response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xsha1('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 85C7C35F151659B612C67ED74C4760A78D89F4C8
}
});
With the xsha256
method you can retrieve the SHA256 checksum for a file on the server
that accepts the XSHA256 command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XSHA256 response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xsha256('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 06FB0EF81B1DC52CB18E1884211F18E1E2423A5B7B00978BD4DF4D97DCB9FF3C
}
});
With the xsha512
method you can retrieve the SHA512 checksum for a file on the server
that accepts the XSHA512 command. The method accepts a callback with the signature err, checksum
, in which err
is the error
response coming from the server (usually a 4xx or 5xx error code), or an error
indicating the XSHA512 response couldn't be parsed, and checksum
is a string containing the checksum.
Ftp.xsha512('myfile.txt', (err, checksum) => {
if (err) {
console.log(err);
} else {
console.log(checksum);
// Prints something like
// 44C4541AB7A3E73F29BAEBE5EE80B522D67204EA7BABEB7E7DC243FF87A363FC2F352A9AFC8ECAAB8F364DBDFB58B42E22AAC744CD8226A61FE01C801EAC385B
}
});
Server** | MD5 | XMD5 | XCRC | XSHA | XSHA1 | XSHA256 | XSHA512 |
---|---|---|---|---|---|---|---|
ProFtp+mod_digest | Y | Y | Y | Y | Y | Y | Y |
JScape MFT | - | Y | Y | - | - | - | - |
Serv-U FTP | - | Y | Y | - | Y | Y | Y |
Key | |
---|---|
Y | jsftp-checksum has been successfully tested against this server |
N | The tested ftp server advertises algorithm support, but jsftp-checksum cannot parse it correctly |
- | The tested ftp server (as configured) does not support the algorithm |
* Other Ftp servers may be supported, please report success/failure
** Ftp server support may vary due to version/configuration differences
There are other checksum commands in the wild (and in this list). If you need support for a different one, please open an issue and I'll see if I can add it. Or, add it yourself and submit a pull request :)
FAQs
Adds some checksum comman support to JSFtp
The npm package jsftp-checksum receives a total of 0 weekly downloads. As such, jsftp-checksum popularity was classified as not popular.
We found that jsftp-checksum demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.